<template>
	<!-- 资讯列表 -->
	<view>
		<!-- <view class="nav">
			<uni-nav-bar :border="false" left-icon="left" leftText="返回" title="资讯" />
		</view>
		 -->
		<view class="int">
			<input v-model="params.key" type="text" placeholder="搜索关键字">
			<view @click="search" class="iconfont icon-sousuo"></view>
		</view>

		<view class="ul">
			<view class="li" v-for="item in list" :key="item.id">
				<view class="left">
					<view class="title">
						{{item.title}}
					</view>
					<view class="time">
						2021-07-23
					</view>
				</view>
				<view class="rgt">
					<image src="/static/images/index1.jpg" mode=""></image>
				</view>
			</view>
			
			 
		</view>
	</view>
</template>

<script>
	import {
		getNewsList
	} from '../../api/news.js'
	export default {
		data() {
			return {
				params: {
					type: 0,
					page: 1,
					psize: 15,
					key: ""
				},
				list: []
			}
		},
		onLoad({
			type
		}) {

			this.params.type = type;

			let title = "资讯";
			switch (type) {
				case "1":
					title = "公告";
					break;
				case "2":
					title = "资讯";
					break;
				default:
					break;
			}

			console.log(type, title);

			uni.setNavigationBarTitle({
				title
			})
			this.getData();

		},
		methods: {

search(){
	this.params.page=1;
	this.getData()
},
			async getData() {

				const res = await getNewsList(this.params);
				if (res.errCode === 10000) {
					this.list = res.data.list;
				}


			}
		}
	}
</script>

<style lang="scss" scoped>
	@import url('@/static/css/information.css');
</style>